package com.user.manage.util;

public class StringUtil {
    // 生成随机字符串
    static String str = "zxcvbnmlkjhgfdsaQWERTYUIOPASDFGHJKLZXCVBNM1234567890";

    public static void main(String[] args) {
        System.out.println(str.length());
    }

    public static String getRandomString(int length) {
        // 定义一个字符串（A-Z，a-z，0-9）即62位；
        // 由随机数生成器生成length个随机数
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = (int) (Math.random() * str.length());
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }
}
